import axios from 'axios';

// 复用已经创建的axios实例
import { apiClient } from './apiClient';

// 房源API服务
export const houseApi = {
  // 获取房源列表
  getHouseList(params) {
    return apiClient.get('/api/houses', { params });
  },
  
  // 获取房源详情
  getHouseDetail(id) {
    return apiClient.get(`/api/houses/${id}`);
  },
  
  // 搜索房源
  searchHouses(params) {
    return apiClient.get('/api/houses', { params });
  },
  
  // 获取城市列表
  getCities() {
    return apiClient.get('/api/houses/cities');
  },
  
  // 获取区域列表
  getDistricts(city) {
    return apiClient.get(`/api/houses/districts?city=${encodeURIComponent(city)}`);
  },
  
  // 获取社区列表
  getCommunities(city, district) {
    return apiClient.get(`/api/houses/communities?city=${encodeURIComponent(city)}&district=${encodeURIComponent(district)}`);
  },
  
  // 获取推荐房源
  getRecommendHouses(id) {
    return apiClient.get(`/api/houses/${id}/recommend`);
  },
  
  // 获取筛选选项
  getFilterOptions() {
    return apiClient.get('/api/houses/filter-options');
  },
  
  // 获取房源对比数据
  compareHouses(ids) {
    return apiClient.post('/api/houses/compare', { ids });
  }
}; 